package wsz.provider.service.impl;

import wsz.service.MethodService;

import java.util.Random;

/**
 * @author wsz
 * @date 2021/12/15 14:03
 **/
public class MethodServiceImpl implements MethodService {

    private Random random = new Random();

    @Override
    public String methodA(String msg) {
        methodSleep("methodA");
        return msg;
    }

    @Override
    public String methodB(String msg) {
        methodSleep("methodB");
        return msg;
    }

    @Override
    public String methodC(String msg) {
        methodSleep("methodC");
        return msg;
    }

    private void methodSleep(String msg) {
        try {
            int nextInt = random.nextInt(100);
            System.out.println(msg + " 即将休眠:" + nextInt + "ms");
            Thread.sleep(nextInt);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
}
